package com.ruoyi.web.controller.category;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.category.domain.SysBackpack;
import com.ruoyi.category.service.ISysBackpackService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 背包Controller
 * 
 * @author YJF
 */
@RestController
@RequestMapping("/backpack")
public class SysBackpackController extends BaseController
{
    @Autowired
    private ISysBackpackService sysBackpackService;

    /**
     * 查询背包列表
     */
    @PreAuthorize("@ss.hasPermi('category:backpack:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBackpack sysBackpack)
    {
        startPage();
        List<SysBackpack> list = sysBackpackService.selectSysBackpackList(sysBackpack);
        return getDataTable(list);
    }

    /**
     * 获取背包详细信息
     */
    @PreAuthorize("@ss.hasPermi('category:backpack:query')")
    @GetMapping(value = "/{backpackId}")
    public AjaxResult getInfo(@PathVariable("backpackId") Long backpackId)
    {
        return AjaxResult.success(sysBackpackService.selectSysBackpackByBackpackId(backpackId));
    }

    /**
     * 新增背包
     */
    @PreAuthorize("@ss.hasPermi('category:backpack:add')")
    @Log(title = "背包", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBackpack sysBackpack)
    {
        return toAjax(sysBackpackService.insertSysBackpack(sysBackpack));
    }

    /**
     * 修改背包
     */
    @PreAuthorize("@ss.hasPermi('category:backpack:edit')")
    @Log(title = "背包", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBackpack sysBackpack)
    {
        return toAjax(sysBackpackService.updateSysBackpack(sysBackpack));
    }

    /**
     * 删除背包
     */
    @PreAuthorize("@ss.hasPermi('category:backpack:remove')")
    @Log(title = "背包", businessType = BusinessType.DELETE)
	@DeleteMapping("/{backpackIds}")
    public AjaxResult remove(@PathVariable Long[] backpackIds)
    {
        return toAjax(sysBackpackService.deleteSysBackpackByBackpackIds(backpackIds));
    }
}
